package com.hulk.boot;

import org.springframework.boot.Banner;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.context.support.ReloadableResourceBundleMessageSource;
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;

import com.google.common.base.Objects;

import lombok.extern.slf4j.Slf4j;



/** 
* @author 作者  cmt
* 类说明 
*/
//@SpringBootApplication
@Slf4j
@Configuration
@EnableAutoConfiguration
@ComponentScan(basePackages="com.hulk.boot",includeFilters={@Filter( type = FilterType.ANNOTATION,  value ={com.alibaba.dubbo.config.annotation.Service.class}),@Filter(type = FilterType.ANNOTATION,  value ={com.alibaba.dubbo.config.annotation.Reference.class})})
public class BootprototypeWebApplication {
	
	
	public static void main(String[] args) {
		
		
		String profile="local";
		if(args==null||args.length<=0){
			profile="local";
		}else if(Objects.equal("local", args[0])){
			profile="local";
		}else if(Objects.equal("product", args[0])){
			profile="product";
		}else {
			throw new RuntimeException("profile args is error !!!");
		}
	   	;
		ConfigurableApplicationContext  applicationContext  =	new SpringApplicationBuilder().sources(BootprototypeWebApplication.class).bannerMode(Banner.Mode.OFF).profiles(profile).run(args);
		
		String activeProfiles = String.valueOf(applicationContext.getEnvironment().getActiveProfiles());
		System.setProperty("spring.profiles.active", activeProfiles);
		log.info("activeProfiles:" + activeProfiles);
	    
	}
}
